package com.it.myh;

public class LocationComparator {
    private static final double TOLERANCE = 0.0001; // 容差值，根据需要进行调整

    public static boolean areLocationsSame(Location location1, Location location2) {
        double latitudeDifference = Math.abs(location1.getLatitude() - location2.getLatitude());
        double longitudeDifference = Math.abs(location1.getLongitude() - location2.getLongitude());

        if (latitudeDifference <= TOLERANCE && longitudeDifference <= TOLERANCE) {
            return true;
        } else {
            return false;
        }
    }

    public static void main(String[] args) {
        // 示例用法
        Location location1 = new Location(40.7128, -74.0060);
        Location location2 = new Location(40.7129, -74.0061);
        boolean sameLocation = areLocationsSame(location1, location2);
        System.out.println("Locations are the same: " + sameLocation);
    }
}

class Location {
    private double latitude;
    private double longitude;

    public Location(double latitude, double longitude) {
        this.latitude = latitude;
        this.longitude = longitude;
    }

    public double getLatitude() {
        return latitude;
    }

    public double getLongitude() {
        return longitude;
    }
}

